package com.compass.mobile.presenters

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.leanback.widget.Presenter
import com.compass.mobile.R
import com.compass.mobile.framework.utils.DateUtils
import com.compass.mobile.models.CaseHistory
import com.compass.mobile.models.OrderBean
import dp2px
import setUrlRound

/**
 * Description：
 * Date:2024/6/19 11:22
 */
class CaseHistoryPresenter : Presenter() {

    override fun onCreateViewHolder(viewGroup: ViewGroup): ViewHolder {
        val view = LayoutInflater.from(viewGroup.context)
            .inflate(R.layout.item_case_history, viewGroup, false)
        return ViewHolder(view)
    }

    override fun onBindViewHolder(viewHolder: Presenter.ViewHolder, item: Any) {
        if (item is CaseHistory) {
            val vh = viewHolder as ViewHolder
            vh.tvDoctorName.text = item.doctorName
            vh.tvPositionName.text = item.positionName
            vh.tvDepartmentName.text = item.departmentName
            vh.tvDiagnoseName.text = item.diagnosisText
            vh.tvConsultationDate.text = "创建时间：${DateUtils.conversionTime(item.consultationDate,DateUtils.FORMAT_TWO)}"
            vh.imgHead.setUrlRound(item.avatar, dp2px(5f))


        }
    }

    override fun onUnbindViewHolder(viewHolder: Presenter.ViewHolder) {

    }


    class ViewHolder(view: View) : Presenter.ViewHolder(view) {

        var tvPositionName: TextView = view.findViewById(R.id.tvPositionName)
        var tvDepartmentName: TextView = view.findViewById(R.id.tvDepartmentName)
        var tvDoctorName: TextView = view.findViewById(R.id.tvDoctorName)
        var tvDiagnoseName: TextView = view.findViewById(R.id.tvDiagnoseName)
        var tvConsultationDate: TextView = view.findViewById(R.id.tvConsultationDate)
        var imgHead: ImageView = view.findViewById(R.id.imgHead)
        var itemView: ConstraintLayout = view.findViewById(R.id.itemView)


    }
}
